package com.example.communitypro.controller;

import com.example.communitypro.pojo.LabelRelation;
import com.example.communitypro.service.LabelRelationService;
import com.example.communitypro.util.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/labelRelation")
public class LabelRelationController {
    @Autowired
    private LabelRelationService labelRelationService;
    @ResponseBody
    @RequestMapping(value = "/changeLabelRe")
    @CrossOrigin
    public Result changeLabelRe(@RequestBody List<LabelRelation> records){
        return labelRelationService.changeLabelRe(records);
    }

    @ResponseBody
    @RequestMapping(value = "/test")
    @CrossOrigin
    public Result test(@RequestBody List<LabelRelation> records){
        System.out.println(records);
        for (LabelRelation record : records) {
            System.out.println(record);
        }
        return Result.ok();
    }


    @ResponseBody
    @RequestMapping(value = "/queryLabelByob")
    @CrossOrigin
    public  Result queryLabelByob(Integer obNo,Integer obType){
        return labelRelationService.queryByOb(obNo,obType);
    }
    @ResponseBody
    @RequestMapping(value = "/queryPostByLabel")
    @CrossOrigin
    public Result queryPostByLabel(Integer labelNo){
        return labelRelationService.queryObByLabel(labelNo);
    }
    @ResponseBody
    @RequestMapping(value = "/recommendPost")
    @CrossOrigin
    public  Result RecommendPost(Integer userNo){
        return  labelRelationService.recommendPost(userNo);
    }
}
